package io.github.biezhi.elves.mapper;

import java.math.BigDecimal;
import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import io.github.biezhi.elves.model.CompAnnualReports;
import io.github.biezhi.elves.qcc.model.CompAnalysis;
import io.github.biezhi.elves.qcc.model.CompBasic;
import io.github.biezhi.elves.qcc.model.CompBasicInfo;
import io.github.biezhi.elves.qcc.model.CompBidding;
import io.github.biezhi.elves.qcc.model.CompChangeRecord;
import io.github.biezhi.elves.qcc.model.CompQccCrawl;
import io.github.biezhi.elves.qcc.model.CompQuota;
import io.github.biezhi.elves.qcc.model.OutboundInvestment;

public interface QccBiddingMapper {

	/**
	 * 查询未爬取的工商企业，即IS_SPIDER=0
	 * @return
	 */
	@Select("select comp_id as compId,comp_name as compName from t_comp_bid where is_spider = 0 limit #{num}")
	public List<CompBasic> queryCompBasic(Integer num);
	
	/**
	 * 根据compId更新爬取状态,0表示未爬取，1表示已爬取，2表示爬取异常
	 * @param compId
	 */
	@Update("update t_comp_bid set is_spider=#{state} where comp_id=#{compId}")
	void updateSpiderBidState(@Param("compId") Long compId,@Param("state") Integer state);

	/**
	 * 将爬取出来的数据存放到数据库表中
	 */
	@Insert("INSERT INTO t_comp_bid_url (comp_id,comp_name, bidding_title, bidding_title_url) "
			+"VALUES (#{compId},#{compName}, #{biddingTitle}, #{biddingTitleUrl})")
	public void insertSpiderBidData(CompBidding compBidding);
	
}
